function check_ROIs(ExpGroup,pl)

for fnd=1:length(ExpGroup)
    adata_dir = '\\argon.fmi.ch\keller.g\AData\';
    display(['Exp: ' num2str(ExpGroup(fnd)) ' *****************************']);
    [adata_file,mouse_id,userID]=find_adata_file(ExpGroup(fnd),adata_dir);
    orig{fnd}=load([adata_dir userID '\' mouse_id '\' adata_file],'ROIs','template','ROItrans');
end

if length(ExpGroup)>4
    x=4;
    y=2;
else
    x=length(ExpGroup);
    y=1;
end


figure;
% set(gcf,'Position',[80         380        1171         511])
for und=1:length(orig)
    orig_template=orig{und}.template{pl};
    template=orig{und}.template{pl};
    win_size = round(min(size(template))/20);
    template=template-min(template(:));
    orig_template=orig_template-min(orig_template(:));
    local_average = filter2(ones(win_size)/win_size^2,orig_template);
    ot_fil = orig_template./local_average;
    local_average = filter2(ones(win_size)/win_size^2,template);
    t_fil = template./local_average;
    if size(ot_fil,2)>size(t_fil,2)
        ot_fil=ot_fil(:,1:size(t_fil,2));
    elseif size(ot_fil,2)<size(t_fil,2)
        ot_fil(:,end+1:size(t_fil,2))=0;
    end
    %     h.f=figure('menubar','none','color','k');
    %     h.a1=axes('position',[0 0 0.975 1]);
    %     axis off
    %     h.a2=axes('position',[0.975 0 0.025 1],'color','k');
    %     axis off
    t_mask_c{und}=zeros(size(t_fil));
    if isfield(orig{und},'ROIs')
        for ind=1:length(orig{und}.ROIs{pl})
            try
%                 if sum(orig{und}.ROItrans{pl})==0
%                     t_mask_c{und}(orig{und}.ROIs{pl}(ind).indices)=und;
%                 else
%                     curr_ind=orig{und}.ROIs{pl}(ind).indices;
%                     curr_ind=curr_ind-orig{und}.ROItrans{pl}(1);
%                     curr_ind=curr_ind-(orig{und}.ROItrans{pl}(2)*size(t_fil,1));
%                     t_mask_c{und}(curr_ind)=und;
%                 end
                
                
                t_mask_c{und}(orig{und}.ROIs{pl}(ind).indices)=und;
                
                
                
                %                 if sum(orig{und}.ROIs{pl}(ind).shift)~=0 | sum(orig{und}.ROItrans{pl})~=0
                %                     curr_ind=orig{und}.ROIs{pl}(ind).indices;
                %                     curr_ind=curr_ind-orig{und}.ROIs{pl}(ind).shift(1);
                %                     curr_ind=curr_ind-(orig{und}.ROIs{pl}(ind).shift(2)*size(t_fil,1));
                %
                %                     curr_ind=curr_ind-orig{und}.ROItrans{pl}(1);
                %                     curr_ind=curr_ind-(orig{und}.ROItrans{pl}(2)*size(t_fil,1));
                %
                %                     t_mask_c{und}(curr_ind)=und;
                %                 else
                %                     t_mask_c{und}(orig{und}.ROIs{pl}(ind).indices)=und;
                %                 end
            catch
                disp(['ROI nbr. ' num2str(ind) ' has moved off of the frame'])
            end
        end
    end
    subplot(y,x,und)
    title(['Exp ' num2str(ExpGroup(und))])
    imagesc(t_mask_c{und})
    axis off
    box off
end

for tnd=1:length(t_mask_c)
    new_mask(:,:,tnd)=t_mask_c{tnd};
end
figure;
% set(gcf,'Position',[-1919           1        1920        1004])
imagesc(mean(new_mask,3))
axis off
box off
colorbar